package com.mc.moring.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.mc.moring.base.BaseApplication;



public class SharePreUtil {

    private static String CONFIG = "XWS";
    private static SharedPreferences sp;


    /**
     *
     * @param key
     * @param value
     */
    public static void saveStringData(String key, String value) {
        if (sp == null) {
            sp = BaseApplication.getInstance().getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
        }
        sp.edit().putString(key, value).commit();
    }

    /**
     *
     * @param key
     */
    public static String getStringData(String key) {
        if (sp == null) {
            sp = BaseApplication.getInstance().getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
        }
        return sp.getString(key, "");
    }

    /**
     *
     * @param context
     */
    public static void clearData(Context context) {
        if (sp == null) {
            sp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
        }
        SharedPreferences.Editor editor = sp.edit();
        editor.clear();
        editor.commit();
    }
}
